<template>
    <div class="photolist">
        <div class="lef">
            <el-aside width="auto" class="left">
                <el-form>
                    <el-input placeholder="请输入学校名称" style="margin-bottom: 20px;" />
                    <el-tree :data="data" @node-click="handleNodeClick" icon="Plus" />
                </el-form>
            </el-aside>
        </div>
        <div class="rig">
            <div class="top">
                <!-- <span style="white-space: nowrap;line-height: 30px;">发布日期：</span> <el-date-picker type="daterange"
                    range-separator="To" start-placeholder="Start date" end-placeholder="End date" /> -->
                <input type="text" placeholder="请输入姓名">
                <el-button type="primary">查询</el-button>
                <el-button type="primary" color="blue" @click="gophoto"><el-icon>
                        <User />
                    </el-icon>我的相册</el-button>
                <el-button type="primary" @click="gopublish"><el-icon>
                        <FolderAdd />
                    </el-icon>发布相册</el-button>
            </div>
            <div class="box">
                <div class="content" v-for="item, index in list" :key="index">
                    <div class="text">
                        <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
                        <div class="wenzi">
                            <p>{{ item.name }}</p>
                            <p>{{ item.initTime }}</p>
                        </div>
                    </div>
                    <div class="miaoshu">
                        <p>{{ item.detail }}</p>
                    </div>
                    <div class="img">
                        <div class="one" v-for="items, indexs in list[index].photoList">
                            <img :src="items.img" alt="">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router';
import server from '@/api/index'
import { ref, onMounted } from 'vue'
var list = ref()

onMounted(async () => {
    var res = await server.home.photos_getPhotosByPage()
    // console.log(res.data.data.date);
    list.value = res.data.data.date

    list.value.forEach((item: any, index: any) => {
        // console.log(item.photoList);
        for (var key in item.photoList) {
            // console.log(item.photoList[key].img); 
            item.photoList[key].img = "http://43.143.177.23:8080" + item.photoList[key].img
            // console.log(item.photoList[key].img);
        }
    })
})

var router = useRouter()
var gophoto = () => {
    router.push('/myphoto')
}
var gopublish = () => {
    router.push('/publishphoto')
}
const data = [
    {
        label: '全部',
        children: [
            {
                label: '小学',
                children: [
                    {
                        label: '实验小学',
                        children: [
                            {
                                label: '一年级',
                                children: [
                                    {
                                        label: '一年级一班'
                                    },
                                    {
                                        label: '一年级二班'
                                    },
                                    {
                                        label: '一年级三班'
                                    },
                                ]
                            },
                            {
                                label: '二年级',
                                children: [
                                    {
                                        label: '二年级一班'
                                    },
                                    {
                                        label: '二年级二班'
                                    },
                                    {
                                        label: '二年级三班'
                                    },
                                ]
                            },
                            {
                                label: '三年级',
                                children: [
                                    {
                                        label: '三年级一班'
                                    },
                                    {
                                        label: '三年级二班'
                                    },
                                    {
                                        label: '三年级三班'
                                    },
                                ]
                            },
                        ]
                    }
                ]
            },
        ],
    },
]
var handleNodeClick = () => {
    // console.log(11);
}
</script>

<style scoped>
.photolist {
    height: 100%;
    width: 100%;
    background: #f7f7f7;
    display: flex;
}

.lef {
    background: #fff;
    width: 20%;
    height: 700px;
    padding: 10px;
}

.rig {
    width: 80%;
    margin-left: 10px;
    background: #fff;
}

.el-menu {
    border-right: none;
}

.top {
    width: 95%;
    height: 50px;
    margin: 20px auto;
    display: flex;
    font-size: 14px;
}

.top input {
    height: 30px;
    outline: none;
    border-radius: 5px;
    border: 1px solid #ccc;
    margin: 0 10px;
    padding-left: 10px;
}

.el-tree {
    --el-tree-node-hover-bg-color: none
}

.box {
    width: 100%;
    height: 600px;
    overflow-y: auto;
}

.content {
    width: 100%;
    margin: 30px auto 0 auto;
}

.text {
    width: 100%;
    display: flex;
}

.wenzi {
    margin-left: 30px;
    font-size: 14px;
    color: #ccc;
}

.wenzi p:nth-child(2) {
    line-height: 28px;
}

.miaoshu {
    width: 400px;
    margin-left: 70px;
    line-height: 60px;
}

.img {
    width: 800px;
    margin-left: 70px;
    height: 500px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 50px;
    display: flex;
    flex-wrap: wrap;
    justify-content: start;
}

.one {
    width: 30%;
    margin: 0 20px 0 0;
    height: 210px;
    border-radius: 5px;
}

.one img {
    width: 100%;
    height: 100%;
}
</style>